package com.xin;

// 懒汉模式  有线程安全问题
public class Singleton1 {
    public Singleton1() {
    }
    private static volatile Singleton1 singlegton;

    public synchronized static Singleton1 getSinglegton() {
        if(null == singlegton) {
            singlegton = new Singleton1();
            System.out.println("实例化了一个单例: "+singlegton);
        }
        return singlegton;
    }
}
